<%--
    Document   : index
    Created on : Nov 22, 2009, 5:31:04 PM
    Author     : Jeremy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="jhu.profiteer.data.Location" %>
<%@ page import="jhu.profiteer.data.LocationJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Locations";
    String cssFile = "/profiteer-game/css/profiteer.css";
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <%
                  LocationJpaController jc = new LocationJpaController();
                  List<Location> locations = jc.findLocationEntities();

                  if(0 == locations.size())
                  {
                %>
                  <p>There are no locations available!</p>
                <%
                  }
                  else
                  {
                %>
                <table>
                  <tr>
                    <th id="left">Name</th>
                    <th id="left">Description</th>
                    <th id="left">X</th>
                    <th id="left">Y</th>
                  </tr>
                  <%
                    for(Location l : locations)
                    {
                  %>
                  <tr>
                    <td><%= l.getName() %></td>
                    <td><%= l.getDescription() %></td>
                    <td><%= l.getX() %></td>
                    <td><%= l.getY() %></td>
                    <td><form action="location?locationId=<%= l.getId() %>" method="post"><input type="submit" name="submit" value="Edit" /></form></td>
                    <td><form action="processLocation?locationId=<%= l.getId() %>" method="post"><input type="submit" name="submit" value="Delete" /></form></td>
                  </tr>
                  <% } %>
                </table>
                <%
                  }
                %>
                <a href="location">Add Location</a>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>
